#include <stdio.h>
#include <stdlib.h>

typedef struct _node {
	int value;
	struct _node* next;
}Node;

typedef struct _list {
	Node* head;
	Node* last;
}List;

void solve();

List list_create() {
	List a;
	a.head = NULL;
	a.last = NULL;
	return a;
}

List* list_append(List* pList, int value) {
	Node* p = (Node*)malloc(sizeof(Node));
	p->value = value;
	p->next = NULL;
	Node* last = pList->head;
	if (pList->last) {
		pList->last->next = p;
		pList->last = p;
	}
	else {
		pList->head = p;
		pList->last = p;
	}
	return pList;
}

void list_free(List* pList) {
	Node* p = pList->head;
	Node* q = p;
	while (q) {
		p = q->next;
		free(q);
		q = p;
	}
}

void list_print(List* pList) {
	Node* p = pList->head;
	while (p) {
		printf("%d ", p->value);
		p = p->next;
	}
	printf("\n");
}

void list_reversed(List* pList) {
	Node* h = NULL;
	Node* p = pList->head;
	Node* q = NULL;
	while (p) {
		q = p->next;
		p->next = h;
		h = p;
		p = q;
	}
	pList->head = h;
}

void list_input(List* pList) {
	int n=0;
	while (n != -1) {
		scanf("%d", &n);
		if (n != -1) {
			list_append(pList, n);
		}
	}
}

void solve() {
	List list = list_create();
	list_input(&list);
	list_reversed(&list);
	list_print(&list);
	list_free(&list);
}

int main()
{
	solve();
	return 0;
}